import React from "react";
import Title from "../components/Title";
import SDTable from "../dataManage/SDTable";
import api from "../../api";
import { render } from "@testing-library/react";
import { Button, message } from "antd";
import moment from "moment";
//import './index.scss'
export default function YdxxManage() {
  const userId = localStorage.getItem("userId");
  const formRef = React.useRef();
  const actionRef = React.useRef();
  const columns = [
    {
      title: "路线名称",
      dataIndex: "name",
      width: 150,
      ellipsis: true,

    },
    {
      title: "站点名称",
      dataIndex: "stationName",
      width: 150,
      ellipsis: true,
      hideInSearch: true,

    },
   
  
    // {
    //   title: "预定日期",
    //   dataIndex: "reservationDate",
    //   width: 150,
     
    //   render: (text, record) => {
    //     return moment(record.reservationDate).format("YYYY-MM-DD");
    //   },
    //   ellipsis: true,
    // },
    {
      title: "预定时间",
      dataIndex: "startTime",
      width: 150,
      ellipsis: true,
      hideInSearch: true,

    },
    {
      title: "预定状态",
      dataIndex: "xlzt",
      width: 150,
      ellipsis: true,
      render: (text, record) => {
        return "已预定";
      },
      hideInSearch: true,

    },
    {
      title: "操作",
      dataIndex: "action",
      hideInSearch: true,
      width: 150,
      fixed: "right",
      render: (text, record) => (
        <Button type="primary" onClick={() => handleOrder(record.routeId)}>取消预约</Button>
      ),
    
    }
   
  ];
  const handleOrder = (routeId) => {
    api.cancelOrder({routeId,userId}).then((res) => {
      if (res.success) {
        message.success(res.message);
        actionRef.current.reload();
      } else {
        message.error(res.message);
      }
    });
  };
  return (
    <div className="style">
      <div style={{ padding: "0 100px" }}>
        <Title title={"预定信息"}></Title>
        <SDTable
          formRef={formRef}
          actionRef={actionRef}
           requestApi={api.ydxx}
          columns={columns}
          params={{userId:localStorage.getItem("userId")}}
          options={false}
        //   search={false}
        ></SDTable>
      </div>
    </div>
  );
}
